package model

import (
	"gorm.io/gorm"
	"time"
	"weibo_1006/global"
)

type Topic struct {
	Id        uint32         `gorm:"column:id;type:int UNSIGNED;comment:id;primaryKey;not null;" json:"id"`        // id
	Name      string         `gorm:"column:name;type:varchar(30);comment:话题名字;not null;" json:"name"`              // 话题名字
	CreateNum int32          `gorm:"column:create_num;type:int;comment:参与量;not null;default:0;" json:"create_num"` // 参与量
	CreatedAt time.Time      `gorm:"column:created_at;type:datetime(3);not null;default:CURRENT_TIMESTAMP(3);" json:"created_at"`
	UpdatedAt time.Time      `gorm:"column:updated_at;type:datetime(3);not null;default:CURRENT_TIMESTAMP(3);" json:"updated_at"`
	DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;type:datetime(3);default:NULL;" json:"deleted_at"`
}

func (t *Topic) TableName() string {
	return "topic"
}

// 话题创建
func (t *Topic) AddTopic() error {
	return global.DB.Create(&t).Error
}
